﻿using Devonline.AspNetCore.OData;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Devonline.Identity.Admin;

/// <summary>
/// 基于 OData 和 DataService 的数据增删改查的基础控制器
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TKey">主键类型</typeparam>
[Authorize]
[ApiController]
[Route("api/[controller]")]
public abstract class ODataServiceController<TEntitySet, TKey> :
    ODataServiceController<IdentityDbContext, TEntitySet, TKey>
    where TEntitySet : class, IEntitySet<TKey>, new()
    where TKey : IConvertible
{
    public ODataServiceController(
        ILogger<ODataServiceController<TEntitySet, TKey>> logger,
        IDataService<TEntitySet, TKey> dataService
        ) : base(logger, dataService) { }
}

/// <summary>
/// 基于字符串作为主键的 OData 和 DataService 的数据增删改查的基础控制器
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
[Authorize]
[ApiController]
[Route("api/[controller]")]
public abstract class ODataServiceController<TEntitySet> :
    ODataServiceController<TEntitySet, string>
    where TEntitySet : class, IEntitySet, new()
{
    public ODataServiceController(
        ILogger<ODataServiceController<TEntitySet>> logger,
        IDataService<TEntitySet> dataService
        ) : base(logger, dataService) { }
}